package com.ocean.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ocean.common.annotation.Log;
import com.ocean.common.enums.BusinessType;
import com.ocean.system.domain.OTouchstone;
import com.ocean.system.service.IOTouchstoneService;
import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.utils.poi.ExcelUtil;
import com.ocean.common.core.page.TableDataInfo;

/**
 * 预报检验任务Controller
 * 
 * @author ocean
 * @date 2025-09-17
 */
@Controller
@RequestMapping("/system/touchstone")
public class OTouchstoneController extends BaseController
{
    private String prefix = "system/sysrwgl";

    @Autowired
    private IOTouchstoneService oTouchstoneService;

    @RequiresPermissions("system:touchstone:view")
    @GetMapping()
    public String touchstone()
    {
        return prefix + "/touchstone";
    }

    /**
     * 页面
     * @return
     */
    @RequiresPermissions("system:sysrwgl:view")
    @RequestMapping("/index")
    public String index() {
        return "system/sysrwgl/index";
    }
    /**
     * 查询预报检验任务列表
     */
    @RequiresPermissions("system:touchstone:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OTouchstone oTouchstone)
    {
        startPage();
        List<OTouchstone> list = oTouchstoneService.selectOTouchstoneList(oTouchstone);
  /*      List<OTouchstone> list =oTouchstoneService.getlistpage(oTouchstone);*/
        return getDataTable(list);
    }
    /*@RequiresPermissions("system:touchstone:list")
    @PostMapping("/list")
    @ResponseBody
    public List<OTouchstone> list(OTouchstone oTouchstone)
    {
        *//*startPage();
        List<OTouchstone> list = oTouchstoneService.selectOTouchstoneList(oTouchstone);*//*
        List<OTouchstone> list =oTouchstoneService.getlistpage(oTouchstone);
        return list;
    }*/

    /**
     * 导出预报检验任务列表
     */
    @RequiresPermissions("system:touchstone:export")
    @Log(title = "预报检验任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OTouchstone oTouchstone)
    {
        List<OTouchstone> list = oTouchstoneService.selectOTouchstoneList(oTouchstone);
        ExcelUtil<OTouchstone> util = new ExcelUtil<OTouchstone>(OTouchstone.class);
        return util.exportExcel(list, "预报检验任务数据");
    }

    /**
     * 新增预报检验任务
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存预报检验任务
     */
    @RequiresPermissions("system:touchstone:add")
    @Log(title = "预报检验任务", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OTouchstone oTouchstone)
    {
        return toAjax(oTouchstoneService.insertOTouchstone(oTouchstone));
    }

    /**
     * 修改预报检验任务
     */
    @RequiresPermissions("system:touchstone:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        OTouchstone oTouchstone = oTouchstoneService.selectOTouchstoneById(id);
        mmap.put("oTouchstone", oTouchstone);
        return prefix + "/edit";
    }

    /**
     * 修改保存预报检验任务
     */
    @RequiresPermissions("system:touchstone:edit")
    @Log(title = "预报检验任务", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OTouchstone oTouchstone)
    {
        return toAjax(oTouchstoneService.updateOTouchstone(oTouchstone));
    }

    /**
     * 删除预报检验任务
     */
    @RequiresPermissions("system:touchstone:remove")
    @Log(title = "预报检验任务", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(oTouchstoneService.deleteOTouchstoneByIds(ids));
    }
}
